package com.team.panicgame.screens.vudduu;

import java.io.IOException;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.math.Vector2;
import com.team.panicgame.GameConstants;
import com.team.panicgame.PanicGame;
import com.team.panicgame.input.GameInputListener;
import com.team.panicgame.models.FirstGameWorld;
import com.team.panicgame.models.InputStatus;

import com.team.panicgame.models.vudduu.VudduuPlayer;
import com.team.panicgame.models.vudduu.VudduuWorld;
import com.team.panicgame.view.vudduu.VudduuRenderer;


public class VudduuScreen implements Screen {
	private VudduuWorld world;
	private VudduuPlayer player;
	private VudduuRenderer renderer;
	private InputStatus inputStatus;
	private PanicGame ourGdxGame;
	
	public VudduuScreen(PanicGame ourGdxGame){
		this.ourGdxGame = ourGdxGame;
	}
	
	@Override
	public void show() {
		inputStatus = new InputStatus();
		try {
			world = new VudduuWorld(inputStatus);
		} catch (IOException e) {
			e.printStackTrace();
		}
		player = new VudduuPlayer(world, 50);
		renderer = new VudduuRenderer(player, world);
		
		GameInputListener gameInputListener = new GameInputListener(inputStatus);
		InputMultiplexer multiplexer = new InputMultiplexer(gameInputListener, new GestureDetector(gameInputListener));
		
		Gdx.input.setInputProcessor(multiplexer);		
	}
	
	@Override
	public void render(float delta) {
		world.update(delta);
		player.update(world, delta);
		renderer.render();
	}

	@Override
	public void resize(int width, int height) {
		renderer.resize(width, height);
	}

	@Override
	public void hide() {
		Gdx.input.setInputProcessor(null);
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void dispose() {
		Gdx.input.setInputProcessor(null);
	}
}
